program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type
  pelement = ^element;
  element = record
    value : integer;
    next : pelement;
  end;

procedure ATB ( var head:pelement; num:integer);
var tmp:pelement;
begin
  tmp:=head;
  new (head);
  head^.next:=tmp;
  head^.value:=num;
end;

procedure ATE (var head:pelement; num:integer);
var current:pelement;
begin
  if (head<>nil) then
  begin
    current:=head;
    while(current^.next<>nil) do
      current:=current^.next;
    new(current^.next);
    current^.next.value:=num;
    current^.next.next:=nil;
  end else
  ATB (head, num);

end;

procedure replace (var head:pelement; n, a:integer);
var i, tmp:integer;
    current, output :pelement;
begin
  current:=head;
  output:=head;
  for i:=1 to (a-1) do
    current:=current^.next;
  for i:=1 to (n-a) do
    output:=output^.next;
  tmp:=current^.value;
  current^.value:=output^.value;
  output^.value:=tmp;
end;

procedure printlist (head:pelement);
var current:pelement;
begin
  current:=head;
  while (current<>nil) do
  begin
    writeln(current^.value);
    current:=current^.next;
  end;
end;


var
  n, i, j, a : integer;
  head : pelement;
  fin : textfile;

begin
assignfile(fin, 'input.txt');
reset(fin);
readln(fin, n);
for i:=1 to n do
begin
  read(fin, j);
  ATE(head, j);
end;
writeln('old');
printlist(head);
for i:=1 to (n div 2) do
if i div 2=0 then
begin
  a:=i;
  replace(head, n, a);
end;
writeln('new');
printlist(head);
readln;

end.
